﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Zove.Runtime.Numerics;

namespace Zove.Desktop.Tools {
    public partial class EquationGroupSolverForm : Form, IDesktopForm {
        public EquationGroupSolverForm() {
            InitializeComponent();
        }

        #region IDesktopForm Members

        public void Execute() {
            List<string> egs = new List<string>();

            foreach (DataGridViewRow r in this.gvEquations.Rows) {
                if (r.Cells["ColEquation"].Value == null) {
                    break;
                }

                egs.Add(r.Cells["ColEquation"].Value.ToString());
            }

            EquationGroup eg = new EquationGroup(egs.ToArray());

            int count = 0;
            double[] rx = eg.Evaluate();

            this.gvResults.Rows.Clear();
            foreach(double result in rx) {
                this.gvResults.Rows.Add(new string[]{
                    "x" + count.ToString(), result.ToString()
                });
                count++;
            }

        }

        public DigitalRune.Windows.TextEditor.TextEditorControl GetTextEditorControl() {
            throw new NotImplementedException();
        }

        public string GetFileName() {
            throw new NotImplementedException();
        }

        public string GetFileExtension() {
            throw new NotImplementedException();
        }

        public void Export(string fileName) {
            throw new NotImplementedException();
        }

        public void Save(string fileName) {
            throw new NotImplementedException();
        }

        public string GetFileFilter() {
            throw new NotImplementedException();
        }

        public virtual string GetColouringScheme() {
            return string.Empty;
        }

        #endregion
    }
}
